﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using HigLabo.Net.Extensions;

namespace HigLabo.Net.Twitter
{
    /// <summary>
    /// 
    /// </summary>
    public class AccountSettings : ResponseObject
    {
        private Boolean _AlwaysUseHttps = false;
        private Boolean _DiscoverableByEmail = false;
        private Boolean _GeoEnabled = false;
        private String _Language = null;
        private Boolean _Protected = false;
        private String _ScreenName = null;
        private Boolean? _ShowAllInlineMedia = null;
        private SleepTime _SleepTime = null;
        private TimeZone _TimeZone = null;
        private TrendLocation _TrendLocation = null;
        private Boolean _UseCookiePersonalization = false;

        /// <summary>
        /// 
        /// </summary>
        public Boolean AlwaysUseHttps
        {
            get { return _AlwaysUseHttps; }
            set { _AlwaysUseHttps = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public Boolean DiscoverableByEmail
        {
            get { return _DiscoverableByEmail; }
            set { _DiscoverableByEmail = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public Boolean GeoEnabled
        {
            get { return _GeoEnabled; }
            set { _GeoEnabled = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public String Language
        {
            get { return _Language; }
            set { _Language = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public Boolean Protected
        {
            get { return _Protected; }
            set { _Protected = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public String ScreenName
        {
            get { return _ScreenName; }
            set { _ScreenName = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public Boolean? ShowAllInlineMedia
        {
            get { return _ShowAllInlineMedia; }
            set { _ShowAllInlineMedia = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public SleepTime SleepTime
        {
            get { return _SleepTime; }
            set { _SleepTime = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public TimeZone TimeZone
        {
            get { return _TimeZone; }
            set { _TimeZone = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public TrendLocation TrendLocation
        {
            get { return _TrendLocation; }
            set { _TrendLocation = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public Boolean UseCookiePersonalization
        {
            get { return _UseCookiePersonalization; }
            set { _UseCookiePersonalization = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public AccountSettings(String jsonText)
        {
            this.SetProperty(jsonText);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public override void SetProperty(string jsonText)
        {
            var d = this.SetData(jsonText);
            this.AlwaysUseHttps = d.ToBoolean("always_use_https") ?? this.AlwaysUseHttps;
            this.DiscoverableByEmail = d.ToBoolean("discoverable_by_email") ?? this.DiscoverableByEmail;
            this.GeoEnabled = d.ToBoolean("geo_enabled") ?? this.GeoEnabled;
            this.Language = d.ToString("language");
            this.Protected = d.ToBoolean("protected") ?? this.Protected;
            this.ScreenName = d.ToString("screen_name");
            this.ShowAllInlineMedia = d.ToBoolean("show_all_inline_media");
            
            this.SleepTime = new SleepTime(d.ToString("sleep_time"));
            if (!String.IsNullOrEmpty(d.ToString("time_zone")))
                this.TimeZone = new TimeZone(d.ToString("time_zone"));
            if (!String.IsNullOrEmpty(d.ToString("trend_location")))
                this.TrendLocation = new TrendLocation(d.ToString("trend_location"));

            this.UseCookiePersonalization = d.ToBoolean("use_cookie_personalization") ?? this.UseCookiePersonalization;
        }
    }
}
